<template>
    <div class="game">
        中国象棋
        <br>
        当前方<span :style="dangqian_num%2==0?'':'color:red;'">{{dangqian_num%2==0?'黑方':'红方'}}</span>
        <p @click="jichu" style="cursor: pointer;">重新开始</p>
        <div class="box">
            <img src="../../assets/xiangqi.jpg" alt="">
            <ul class="ul1">
                <li v-for="(i,index) in qi.hei_list" :class="i.duiwu=='红'?'red':''" :style="index==dangqian_xuanzhong?'background:#ccc;':''" @click="dianji(i,index)" :key="index">
                    {{i.name}}
                </li>
            </ul>
        </div>
        <div class="chi animated bounceOut" v-show="tishi_chi">
            <p :style="shei_chi.duiwu=='红'?'color:red;':''">{{shei_chi.name}}</p>
            <img src="../../assets/images/bpic.588ku.jpg" alt="">
            <p :style="bei_chi.duiwu=='红'?'color:red;':''">{{bei_chi.name}}</p>
        </div>
    </div>
</template>

<script>
export default {
    name: "game",
    data() {
        return {
            dangqian_num:1,
            qi:{
                hei_list:[],
                red_list:[]
            },
            dangqian_xuanzhong:'-1',
            gaoliang_list:[],
            gaoliang_hong_list:[],
            shei_chi:{
                name:'',
                duiwu:''
            },
            bei_chi:{
                name:'',
                duiwu:''
            },
            tishi_chi:false,//提示谁吃谁
        };
    },
    created() {
        this.jichu()
    },
    watch:{
        gaoliang_list(){
            // for(let i=0;i<45;i++){
                this.gaoliang()
            // }
        }
    },
    methods: {
        jichu(){
            let hei_list=[]
            let red_list=[]
            for(let i=0;i<90;i++){
                hei_list.push({
                    name:'',
                    id:'',
                    lie:'黑'
                })
                // red_list.push({
                //     name:'',
                //     id:'',
                //     lie:'红'
                // })
            }
            this.$set(this.qi,'hei_list',hei_list)
            // this.$set(this.qi,'red_list',red_list)
            this.geshi_hua()
        },
        geshi_hua(){ //格式化
            this.qi.hei_list.forEach((item,index)=>{
                if(index==0||index==8){
                    item.name='車';
                    item.id='1';
                    item.duiwu='黑'
                }
                if(index==1||index==7){
                    item.name='马';
                    item.id='2';
                    item.duiwu='黑'
                }
                if(index==2||index==6){
                    item.name='象';
                    item.id='3';
                    item.duiwu='黑'
                }
                if(index==3||index==5){
                    item.name='士';
                    item.id='4';
                    item.duiwu='黑'
                }
                if(index==4){
                    item.name='将';
                    item.id='5';
                    item.duiwu='黑'
                }
                if(index==19||index==25){
                    item.name='炮';
                    item.id='6';
                    item.duiwu='黑'
                }
                if(index==27||index==29||index==31||index==33||index==35){
                    item.name='兵';
                    item.id='7';
                    item.duiwu='黑'
                }
                if(index==54||index==56||index==58||index==60||index==62){
                    item.name='兵';
                    item.id='7';
                    item.duiwu='红'
                }
                if(index==64||index==70){
                    item.name='炮';
                    item.id='6';
                    item.duiwu='红'
                }
                if(index==81||index==89){
                    item.name='車';
                    item.id='1';
                    item.duiwu='红'
                }
                if(index==82||index==88){
                    item.name='马';
                    item.id='2';
                    item.duiwu='红'
                }
                if(index==83||index==87){
                    item.name='象';
                    item.id='3';
                    item.duiwu='红'
                }
                if(index==84||index==86){
                    item.name='士';
                    item.id='4';
                    item.duiwu='红'
                }
                if(index==85){
                    item.name='将';
                    item.id='5';
                    item.duiwu='红'
                }
            })
            // this.qi.red_list.forEach((item,index)=>{
            //     if(index==36||index==44){
            //         item.name='車';
            //         item.id='1';
            //         item.duiwu='红'
            //     }
            //     if(index==37||index==43){
            //         item.name='马';
            //         item.id='2';
            //         item.duiwu='红'
            //     }
            //     if(index==38||index==42){
            //         item.name='象';
            //         item.id='3';
            //         item.duiwu='红'
            //     }
            //     if(index==39||index==41){
            //         item.name='士';
            //         item.id='4';
            //         item.duiwu='红'
            //     }
            //     if(index==40){
            //         item.name='将';
            //         item.id='5';
            //         item.duiwu='红'
            //     }
            //     if(index==19||index==25){
            //         item.name='炮';
            //         item.id='6';
            //         item.duiwu='红'
            //     }
            //     if(index==9||index==11||index==13||index==15||index==17){
            //         item.name='兵';
            //         item.id='7';
            //         item.duiwu='红'
            //     }
            // })
        },
        gaoliang(){
            // console.log(index)
            console.log(this.gaoliang_list)
            // debugger
            var arr = document.getElementsByClassName("ul1");
            if(this.gaoliang_list.length!=0){
                this.gaoliang_list.forEach(item=>{
                    console.log(item)
                    arr[0].children[Number(item)].classList.add('liang')
                })
            }else{
                for(let i=0;i<90;i++){
                    arr[0].children[Number(i)].classList.remove('liang')
                }
            }
        },
        dianji(i,index){
            if(this.dangqian_xuanzhong==-1&&i.name.length!=0){
                let text=this.dangqian_num%2==0?'黑':'红'
                if(text==i.duiwu){
                    console.log(index)
                    this.dangqian_xuanzhong=index
                    console.log(i)
                    this.dangqian_xuanzhong_i=i
                    this.panduan_gaoliang(index,i,'拿起')
                }else{
                    // alert('请点击'+text+'方')
                    this.$message({
                        message: '该'+text+'方走了哟',
                        type: 'warning'
                    });
                }
            }else{
                if(index==this.dangqian_xuanzhong){
                    this.dangqian_xuanzhong=-1
                    this.dangqian_xuanzhong_i=''
                    this.panduan_gaoliang(index,i,'放下')
                }else{
                    if(i.zhi!=undefined&&i.zhi==true){
                        let a=JSON.parse(JSON.stringify(i))
                        let b=JSON.parse(JSON.stringify(this.qi.hei_list[this.dangqian_xuanzhong]))
                        if(a.name.length!=0){
                            this.tishi(b,a)
                        }
                        // setTimeout(() => {
                            this.$set(i,'name',this.qi.hei_list[this.dangqian_xuanzhong].name)
                            this.$set(i,'id',this.qi.hei_list[this.dangqian_xuanzhong].id)
                            this.$set(i,'duiwu',this.qi.hei_list[this.dangqian_xuanzhong].duiwu)
                            this.$set(this.qi.hei_list[this.dangqian_xuanzhong],'name','')
                            this.$set(this.qi.hei_list[this.dangqian_xuanzhong],'id','')
                            this.$set(this.qi.hei_list[this.dangqian_xuanzhong],'duiwu','')
                            this.dangqian_xuanzhong=-1
                            // xcthis.dangqian_xuanzhong_i=''
                            this.dangqian_num=Number(this.dangqian_num)+1
                            this.panduan_gaoliang(index,i,'放下')
                        // }, 10)
                        
                    }
                }
            }
        },
        panduan_gaoliang(index,i,dongzuo){
            let text=this.dangqian_num%2==0?'黑':'红'
            let fan_text=this.dangqian_num%2!=0?'黑':'红'
            console.log(text,fan_text)
            console.log(i)
            if(dongzuo=='拿起'){
                // if(i.duiwu=='黑'){
                    if(i.id=='7'){//  兵没问题了   已测
                        let date=this.huoqu_hang_lie(index)
                        let liang=[]
                        // 兵  9格
                        if(i.duiwu=='黑'){
                            if(date.hang<=8&&(this.qi.hei_list[Number(index)+9].name.length==0||this.qi.hei_list[Number(index)+9].duiwu==fan_text)){
                                liang.push(Number(index)+9)
                                this.$set(this.qi.hei_list[Number(index)+9],'zhi',true)
                            }
                            if(index>=45){
                                if(date.lie>=1&&(this.qi.hei_list[Number(index)-1].name.length==0||this.qi.hei_list[Number(index)-1].duiwu==fan_text)){
                                    liang.push(index-1)
                                    this.$set(this.qi.hei_list[index-1],'zhi',true)
                                }
                                if(date.lie<=7&&(this.qi.hei_list[Number(index)+1].name.length==0||this.qi.hei_list[Number(index)+1].duiwu==fan_text)){
                                    liang.push(index+1)
                                    this.$set(this.qi.hei_list[index+1],'zhi',true)
                                }
                            }
                        }else{
                            if(date.hang>=1&&(this.qi.hei_list[Number(index)-9].name.length==0||this.qi.hei_list[Number(index)-9].duiwu==fan_text)){
                                liang.push(Number(index)-9)
                                this.$set(this.qi.hei_list[Number(index)-9],'zhi',true)
                            }
                            if(index<=44){
                                if(date.lie>=1&&(this.qi.hei_list[Number(index)-1].name.length==0||this.qi.hei_list[Number(index)-1].duiwu==fan_text)){
                                    liang.push(index-1)
                                    this.$set(this.qi.hei_list[index-1],'zhi',true)
                                }
                                if(date.lie<=7&&(this.qi.hei_list[Number(index)+1].name.length==0||this.qi.hei_list[Number(index)+1].duiwu==fan_text)){
                                    liang.push(index+1)
                                    this.$set(this.qi.hei_list[index+1],'zhi',true)
                                }
                            }
                        }
                        this.gaoliang_list=liang
                    }else if(i.id=='6'){// 炮没问题了    已测
                        let date=this.huoqu_hang_lie(index)
                        console.log(date)
                        let liang=[]
                        // 行
                        for(let a=1;a<=Number(index)-date.hang_list[0];a++){
                            if(this.qi.hei_list[Number(index)-a].name.length==0){
                                liang.push(Number(index)-a)
                                this.$set(this.qi.hei_list[Number(index)-a],'zhi',true)
                            }else{
                                for(let b=a+1;b<=Number(index)-date.hang_list[0];b++){
                                    if(this.qi.hei_list[Number(index)-b].duiwu==fan_text){
                                        liang.push(Number(index)-b)
                                        this.$set(this.qi.hei_list[Number(index)-b],'zhi',true)
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        for(let a=1;a<=date.hang_list[8]-Number(index);a++){
                            console.log(this.qi.hei_list[Number(index)+a].duiwu,fan_text)
                            // debugger
                            if(this.qi.hei_list[Number(index)+a].name.length==0){
                                liang.push(Number(index)+a)
                                this.$set(this.qi.hei_list[Number(index)+a],'zhi',true)
                            }else{
                                for(let b=a+1;b<=date.hang_list[8]-Number(index);b++){
                                    if(this.qi.hei_list[Number(index)+b].duiwu==fan_text){
                                        liang.push(Number(index)+b)
                                        this.$set(this.qi.hei_list[Number(index)+b],'zhi',true)
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        // 列
                        for(let a=0;a<date.lie_idx;a++){
                            if(this.qi.hei_list[Number(index)-(a+1)*9].name.length==0){
                                liang.push(Number(index)-(a+1)*9)
                                this.$set(this.qi.hei_list[Number(index)-(a+1)*9],'zhi',true)
                            }else{
                                for(let b=a+1;b<=date.lie_idx;b++){
                                    if(Number(index)-(b+1)*9>=0&&this.qi.hei_list[Number(index)-(b+1)*9].duiwu==fan_text){
                                        liang.push(Number(index)-(b+1)*9)
                                        this.$set(this.qi.hei_list[Number(index)-(b+1)*9],'zhi',true)
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        for(let a=0;a<9-date.lie_idx;a++){
                            if(this.qi.hei_list[Number(index)+(a+1)*9].name.length==0){
                                liang.push(Number(index)+(a+1)*9)
                                this.$set(this.qi.hei_list[Number(index)+(a+1)*9],'zhi',true)
                            }else{
                                for(let b=a+1;b<=9-date.lie_idx;b++){
                                    if(Number(index)+(b+1)*9<=89&&this.qi.hei_list[Number(index)+(b+1)*9].duiwu==fan_text){
                                        liang.push(Number(index)+(b+1)*9)
                                        this.$set(this.qi.hei_list[Number(index)+(b+1)*9],'zhi',true)
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        console.log(liang)
                        this.gaoliang_list=liang
                    }else if(i.id=='1'){//车没有问题了  已测
                        let date=this.huoqu_hang_lie(index)
                        console.log(date)
                        let liang=[]
                        // 行
                        for(let a=1;a<=Number(index)-date.hang_list[0];a++){
                            if(this.qi.hei_list[Number(index)-a].name.length==0||this.qi.hei_list[Number(index)-a].duiwu==fan_text){
                                if(this.qi.hei_list[Number(index)-a].duiwu==fan_text){
                                    liang.push(Number(index)-a)
                                    this.$set(this.qi.hei_list[Number(index)-a],'zhi',true)
                                    break;
                                }else{
                                    liang.push(Number(index)-a)
                                    this.$set(this.qi.hei_list[Number(index)-a],'zhi',true)
                                }
                            }else{
                                break;
                            }
                        }
                        for(let a=1;a<=date.hang_list[8]-Number(index);a++){
                            console.log(this.qi.hei_list[Number(index)+a].duiwu,fan_text)
                            // debugger
                            if(this.qi.hei_list[Number(index)+a].name.length==0||this.qi.hei_list[Number(index)+a].duiwu==fan_text){
                                if(this.qi.hei_list[Number(index)+a].duiwu==fan_text){
                                    liang.push(Number(index)+a)
                                    this.$set(this.qi.hei_list[Number(index)+a+1],'zhi',true)
                                    break;
                                }else{
                                    liang.push(Number(index)+a)
                                    this.$set(this.qi.hei_list[Number(index)+a],'zhi',true)
                                }
                            }else{
                                break;
                            }
                        }
                        // 列
                        for(let a=0;a<date.lie_idx;a++){
                            if(this.qi.hei_list[Number(index)-(a+1)*9].name.length==0||this.qi.hei_list[Number(index)-(a+1)*9].duiwu==fan_text){
                                if(this.qi.hei_list[Number(index)-(a+1)*9].duiwu==fan_text){
                                    liang.push(Number(index)-(a+1)*9)
                                    this.$set(this.qi.hei_list[Number(index)-(a+1)*9],'zhi',true)
                                    break;
                                }else{
                                    liang.push(Number(index)-(a+1)*9)
                                    this.$set(this.qi.hei_list[Number(index)-(a+1)*9],'zhi',true)
                                }
                            }else{
                                break;
                            }
                        }
                        for(let a=0;a<9-date.lie_idx;a++){
                            if(this.qi.hei_list[Number(index)+(a+1)*9].name.length==0||this.qi.hei_list[Number(index)+(a+1)*9].duiwu==fan_text){
                                if(this.qi.hei_list[Number(index)+(a+1)*9].duiwu==fan_text){
                                    liang.push(Number(index)+(a+1)*9)
                                    this.$set(this.qi.hei_list[Number(index)+(a+1)*9],'zhi',true)
                                    break;
                                }else{
                                    liang.push(Number(index)+(a+1)*9)
                                    this.$set(this.qi.hei_list[Number(index)+(a+1)*9],'zhi',true)
                                }
                            }else{
                                break;
                            }
                        }
                        console.log(liang)
                        console.log(this.qi.hei_list)
                        this.gaoliang_list=liang
                    }else if(i.id=='2'){//马没问题了  已测
                        let date=this.huoqu_hang_lie(index)
                        console.log(date)
                        let liang=[]
                        console.log(this.qi.hei_list)
                        if(date.hang<=7&&this.qi.hei_list[index+9].name.length==0){
                            if(date.lie!=0&&(this.qi.hei_list[index+17].duiwu==undefined||this.qi.hei_list[index+17].duiwu.length==0||this.qi.hei_list[index+17].duiwu==fan_text)){
                                liang.push(index+17)
                                this.$set(this.qi.hei_list[index+17],'zhi',true)
                            }
                            if(date.lie!=8&&(this.qi.hei_list[index+19].duiwu==undefined||this.qi.hei_list[index+19].duiwu.length==0||this.qi.hei_list[index+19].duiwu==fan_text)){
                                liang.push(index+19)
                                this.$set(this.qi.hei_list[index+19],'zhi',true)
                            }
                        }
                        if(date.lie>=2&&this.qi.hei_list[index-1].name.length==0){
                            if(date.hang!=9&&(this.qi.hei_list[index+7].duiwu==undefined||this.qi.hei_list[index+7].duiwu.length==0||this.qi.hei_list[index+7].duiwu==fan_text)){
                                liang.push(index+7)
                                this.$set(this.qi.hei_list[index+7],'zhi',true)
                            }
                            if(date.hang!=0&&(this.qi.hei_list[index-11].duiwu==undefined||this.qi.hei_list[index-11].duiwu.length==0||this.qi.hei_list[index-11].duiwu==fan_text)){
                                liang.push(index-11)
                                this.$set(this.qi.hei_list[index-11],'zhi',true)
                            }
                        }
                        if(date.hang>=2&&this.qi.hei_list[index-9].name.length==0){
                            if(date.lie!=0&&(this.qi.hei_list[index-19].duiwu==undefined||this.qi.hei_list[index-19].duiwu.length==0||this.qi.hei_list[index-19].duiwu==fan_text)){
                                liang.push(index-19)
                                this.$set(this.qi.hei_list[index-19],'zhi',true)
                            }
                            if(date.lie!=8&&(this.qi.hei_list[index-17].duiwu==undefined||this.qi.hei_list[index-17].duiwu.length==0||this.qi.hei_list[index-17].duiwu==fan_text)){
                                liang.push(index-17)
                                this.$set(this.qi.hei_list[index-17],'zhi',true)
                            }
                        }
                        if(date.lie<=6&&this.qi.hei_list[index+1].name.length==0){
                            if(date.hang!=0&&(this.qi.hei_list[index-7].duiwu==undefined||this.qi.hei_list[index-7].duiwu.length==0||this.qi.hei_list[index-7].duiwu==fan_text)){
                                liang.push(index-7)
                                this.$set(this.qi.hei_list[index-7],'zhi',true)
                            }
                            if(date.hang!=9&&(this.qi.hei_list[index+11].duiwu==undefined||this.qi.hei_list[index+11].duiwu.length==0||this.qi.hei_list[index+11].duiwu==fan_text)){
                                liang.push(index+11)
                                this.$set(this.qi.hei_list[index+11],'zhi',true)
                            }
                        }
                        this.gaoliang_list=liang
                    }else if(i.id=='3'){//象没问题了  已测
                        let date=this.huoqu_hang_lie(index)
                        console.log(date)
                        let liang=[]
                        if(date.lie>=2&&this.qi.hei_list[index+8]!=undefined&&this.qi.hei_list[index+8].name.length==0){
                            if(((i.duiwu=='黑'&&date.hang<=2)||(i.duiwu=='红'&&date.hang>=5&&date.hang<=7))&&(this.qi.hei_list[index+16].duiwu==undefined||this.qi.hei_list[index+16].duiwu.length==0||this.qi.hei_list[index+16].duiwu==fan_text)){
                                liang.push(index+16)
                                this.$set(this.qi.hei_list[index+16],'zhi',true)
                            }
                        }
                        if(((i.duiwu=='黑'&&date.hang>=2&&date.hang<=4)||(i.duiwu=='红'&&date.hang>=7))&&this.qi.hei_list[index-10]!=undefined&&this.qi.hei_list[index-10].name.length==0){
                            if(date.lie>=2&&(this.qi.hei_list[index-20].duiwu==undefined||this.qi.hei_list[index-20].duiwu.length==0||this.qi.hei_list[index-20].duiwu==fan_text)){
                                liang.push(index-20)
                                this.$set(this.qi.hei_list[index-20],'zhi',true)
                            }
                        }
                        if(((i.duiwu=='黑'&&date.hang>=2&&date.hang<=4)||(i.duiwu=='红'&&date.hang>=7))&&this.qi.hei_list[index-8]!=undefined&&this.qi.hei_list[index-8].name.length==0){
                            if(date.lie<=6&&(this.qi.hei_list[index-16].duiwu==undefined||this.qi.hei_list[index-16].duiwu.length==0||this.qi.hei_list[index-16].duiwu==fan_text)){
                                liang.push(index-16)
                                this.$set(this.qi.hei_list[index-16],'zhi',true)
                            }
                        }
                        // date.lie>=2&&
                        if(((i.duiwu=='黑'&&date.hang<=2)||(i.duiwu=='红'&&date.hang>=5&&date.hang<=7))&&this.qi.hei_list[index+10]!=undefined&&this.qi.hei_list[index+10].name.length==0){
                            if(date.lie<=6&&(this.qi.hei_list[index+20].duiwu==undefined||this.qi.hei_list[index+20].duiwu.length==0||this.qi.hei_list[index+20].duiwu==fan_text)){
                                liang.push(index+20)
                                this.$set(this.qi.hei_list[index+20],'zhi',true)
                            }
                        }
                        this.gaoliang_list=liang  
                    }else if(i.id=='4'){//士没问题了  已测
                        let date=this.huoqu_hang_lie(index)
                        console.log(date)
                        let liang=[]
                        if((index==3||index==66)&&(this.qi.hei_list[index+10].duiwu==undefined||this.qi.hei_list[index+10].duiwu.length==0||this.qi.hei_list[index+10].duiwu==fan_text)){
                            liang.push(index+10)
                            this.$set(this.qi.hei_list[index+10],'zhi',true)
                        }
                        if((index==5||index==68)&&(this.qi.hei_list[index+8].duiwu==undefined||this.qi.hei_list[index+8].duiwu.length==0||this.qi.hei_list[index+8].duiwu==fan_text)){
                            liang.push(index+8)
                            this.$set(this.qi.hei_list[index+8],'zhi',true)
                        }
                        if(index==13||index==76){
                            if(this.qi.hei_list[index-10].duiwu==undefined||this.qi.hei_list[index-10].duiwu.length==0||this.qi.hei_list[index-10].duiwu==fan_text){
                                liang.push(index-10)
                                this.$set(this.qi.hei_list[index-10],'zhi',true)
                            }
                            if(this.qi.hei_list[index-8].duiwu==undefined||this.qi.hei_list[index-8].duiwu.length==0||this.qi.hei_list[index-8].duiwu==fan_text){
                                liang.push(index-8)
                                this.$set(this.qi.hei_list[index-8],'zhi',true)
                            }
                            if(this.qi.hei_list[index+8].duiwu==undefined||this.qi.hei_list[index+8].duiwu.length==0||this.qi.hei_list[index+8].duiwu==fan_text){
                                liang.push(index+8)
                                this.$set(this.qi.hei_list[index+8],'zhi',true)
                            }
                            if(this.qi.hei_list[index+10].duiwu==undefined||this.qi.hei_list[index+10].duiwu.length==0||this.qi.hei_list[index+10].duiwu==fan_text){
                                liang.push(index+10)
                                this.$set(this.qi.hei_list[index+10],'zhi',true)
                            }
                        }
                        if((index==23||index==86)&&(this.qi.hei_list[index-10].duiwu==undefined||this.qi.hei_list[index-10].duiwu.length==0||this.qi.hei_list[index-10].duiwu==fan_text)){
                            liang.push(index-10)
                            this.$set(this.qi.hei_list[index-10],'zhi',true)
                        }
                        if((index==21||index==84)&&(this.qi.hei_list[index-8].duiwu==undefined||this.qi.hei_list[index-8].duiwu.length==0||this.qi.hei_list[index-8].duiwu==fan_text)){
                            liang.push(index-8)
                            this.$set(this.qi.hei_list[index-8],'zhi',true)
                        }
                        this.gaoliang_list=liang
                    }else if(i.id=='5'){
                        let date=this.huoqu_hang_lie(index)
                        console.log(date)
                        let liang=[]
                        if(date.hang!=2&&date.hang!=9&&(this.qi.hei_list[index+9].duiwu==undefined||this.qi.hei_list[index+9].duiwu.length==0||this.qi.hei_list[index+9].duiwu==fan_text)){
                            liang.push(index+9)
                            this.$set(this.qi.hei_list[index+9],'zhi',true)
                        }
                        if(date.lie!=5&&(this.qi.hei_list[index+1].duiwu==undefined||this.qi.hei_list[index+1].duiwu.length==0||this.qi.hei_list[index+1].duiwu==fan_text)){
                            liang.push(index+1)
                            this.$set(this.qi.hei_list[index+1],'zhi',true)
                        }
                        if(date.lie!=3&&(this.qi.hei_list[index-1].duiwu==undefined||this.qi.hei_list[index-1].duiwu.length==0||this.qi.hei_list[index-1].duiwu==fan_text)){
                            liang.push(index-1)
                            this.$set(this.qi.hei_list[index-1],'zhi',true)
                        }
                        if(date.hang!=0&&date.hang!=7&&(this.qi.hei_list[index-9].duiwu==undefined||this.qi.hei_list[index-9].duiwu.length==0||this.qi.hei_list[index-9].duiwu==fan_text)){
                            liang.push(index-9)
                            this.$set(this.qi.hei_list[index-9],'zhi',true)
                        }
                        this.gaoliang_list=liang
                    }
                // }
            }else{
                this.qi.hei_list.forEach(item=>{
                    this.$set(item,'zhi',false)
                })
                this.gaoliang_list=[]
            }
        },
        huoqu_hang_lie(num){
            // 行
            let list=[
                [],
                [],
                [],
                [],
                [],
                [],
                [],
                [],
                [],
                []
            ]
            list.forEach((item,index)=>{
                let a=[]
                // console.log(index*9)
                for(let i=index*9;i<(index+1)*9;i++){
                    a.push(i)
                }
                list[index]=a
            })
            // 列
            let list2=[]
            for(let i=0;i<9;i++){
                list2.push([])
            }
            list2.forEach((item,index)=>{
                let a=[]
                let b=JSON.parse(JSON.stringify(index))
                a.push(index)
                // console.log(index*9)
                for(let i=0;i<9;i++){
                    a.push(Number(b+9))
                    b=Number(b+9)
                }
                list2[index]=a
            })
            console.log(list2)

            let hang=''
            let hang_list=[]
            list.forEach((item,index)=>{
                item.forEach(ite=>{
                    if(ite==num){
                        hang=index
                        hang_list=item
                    }
                })
            })
            let lie=''
            let lie_list=[]
            let lie_idx=''
            list2.forEach((item,index)=>{
                item.forEach((ite,idx)=>{
                    if(ite==num){
                        lie=index
                        lie_list=item
                        lie_idx=idx
                    }
                })
            })
            console.log(hang,lie)
            console.log(hang_list,lie_list)
            // debugger
            let obj={
                hang,
                lie,
                hang_list,
                lie_list,
                lie_idx
            }
            return obj
        },
        tishi(b,a){//提示谁吃谁
            this.shei_chi=b
            this.bei_chi=a
            this.tishi_chi=true
            setTimeout(() => {
                if(a.id=='5'){
                    alert(b.duiwu+'方获胜')
                }
                this.tishi_chi=false
            }, 3000)
        }
//         setTimeout(() => {

// 　　　　}, 0)
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.game .box{
    height:800px;
    width:800px;
    border:1px solid red;
    position: relative;
}
.box img{
    height:800px;
    width:800px;
    position: absolute;
    opacity: .5;
    /* z-index: ; */
}
.box .ul1{
    position: absolute;
    height:350px;
    width:800px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}
.box .ul1 li{
    /* border:1px solid red; */
    cursor: pointer;
}
.box .ul1 li:nth-child(46),li:nth-child(47),li:nth-child(48),li:nth-child(49),li:nth-child(50),li:nth-child(51),li:nth-child(52),li:nth-child(53),li:nth-child(54){
    margin-top: 90px;
}
.box .ul2{
    position: absolute;
    height:350px;
    width:800px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    top: 450px;
}
.box .ul1 li{
    height:70px;
    width:82px;
    /* border:1px solid red; */
    display: flex;
    align-items: center;
    justify-content:center;
    font-size: 25px;
    font-weight: 600;
}
.box .ul2 li{
    height:70px;
    width:82px;
    border:1px solid red;
    display: flex;
    align-items: center;
    justify-content:center;
    font-size: 25px;
    font-weight: 600;
}
.liang{
    border:1px solid blue!important;
    background: #fff;
}
.red{
    color:red;
}
.game{
    position: relative;
}
.game .chi{
    background: #fff;
    position: absolute;
    width:300px;
    height:300px;
    top:250px;
    left:250px;
}
.game .chi img{
    height: 200px;
    width: 200px;
    display: block;
    margin: 0 auto;
}
.game .chi p{
    font-size: 50px;
    font-weight: 600;
}
.game .chi p:nth-child(3){
    text-align: right;
}
</style>
